package com.foruo.learn.designmode.flyweight;

import java.util.HashMap;
import java.util.Map;

public class GoodsFactory {

    private static final Map<String,IGoods> goodsMap = new HashMap<>();

    public static IGoods getGoods(String type){
        Goods goods = (Goods)goodsMap.get(type);
        if (goods==null) {
            goods = new Goods(type);
            goodsMap.put(type,goods);
        }
        return goods;
    }

}
